package com.bana.sys.controller;

import com.bana.sys.dao.FunctionDAO;
import com.bana.sys.model.Function;

import com.bana.sys.model.FunctionPageParameter;
import com.bana.sys.utils.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping(value = "/function",method = RequestMethod.POST)
public class FunctionController {

    @Resource
    private FunctionDAO functionDAO;

    /**
     * 查询功能
     * @param request jsbm,gnbm,gnmc,分页
     * @return
     */
    @RequestMapping(value = "/getFunctions.do", method = RequestMethod.POST)
    public PageResponse<Function> getFunctions(@RequestBody TokenRequest<FunctionPageParameter> request) {

        FunctionPageParameter parameter=request.getData();
        parameter.setJsbm(0);
        List<Function> functions = functionDAO.getFunctions(parameter);
        int count=functionDAO.getFunctionCount(parameter);
        return new PageResponse<>(functions,count);
    }

}
